//      https://ac.nowcoder.com/acm/contest/11217/F




#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; ++i)
        cin >> a[i];

    vector<int> dist(n + 1, -1);
    queue<int> q;
    q.push(1);
    dist[1] = 0;

    while (!q.empty())
    {
        int cur = q.front();
        q.pop();
        for (int i = 1; i <= abs(a[cur]); ++i)
        {
            int next = a[cur] > 0 ? cur + i : cur - i;
            if (next >= 1 && next <= n && dist[next] == -1)
            {
                dist[next] = dist[cur] + 1;
                q.push(next);
            }
        }
    }

    cout << dist[n] << endl;
    return 0;
}